<template>
  <div class="ele-body">
    <div class="print">
      <a-button type="primary" @click="print" size="large">打印</a-button>
    </div>
    <div ref="printRef">
      <div class="layui-row header-container">
        <div
          style="font-size:26px;font-weight: bold;display:flex;flex-flow: row nowrap;justify-content:center;margin:0 auto;">
          <div style="">{{ loginUser.organizationFullName }}</div>
          <div style="margin-left:20px;">入库单</div>
        </div>
      </div>
      <div class="layui-row header-container marginTop">
        <div style="width:300px; position:absolute;left:0px;top:0px;">入库单号:{{ entryBillForm.code }}</div>
        <div style="width:250px; position:absolute;right:50px;top:0px;">入库单日期:{{ entryBillForm.entrytime }}</div>
      </div>
      <div class="layui-row header-container">
        <div style="width:300px; position:absolute;left:0px;top:0px;">客户:{{ entryBillForm.supplier }}</div>
      </div>
      <table class="table" cellspacing="0" cellpadding="0">
        <thead>
          <tr>
            <td>产品名称</td>
            <td>规格</td>
            <td>长度</td>
            <td>数量</td>
            <td>重量</td>
            <td>单价</td>
            <td>金额</td>
          </tr>
        </thead>
        <tbody>
          <tr v-for="(item, index) in entryBillSonList.a" :key="index">
            <td>{{ item.productname }}</td>
            <td>{{ item.specification }}</td>
            <td>{{ item.lengths }}</td>
            <td>{{ item.num }}</td>
            <td>{{ item.actualweight }}</td>
            <td>{{ item.price }}</td>
            <td>{{ item.totalprice }}</td>
          </tr>
          <tr v-for="(item, index) in 7 - (entryBillSonList.a.length > 6 ? 7 : entryBillSonList.a.length)" :key="index">
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
          </tr>
          <tr>
            <td style="height: 18px;line-height: 18px;">总计</td>
            <td colspan="5" style="padding: 10px;text-align: left;height: 18px;line-height: 18px;">
              金额合计大写:<span id="priceUpper">{{ smallToBig(entryBillForm.total) }}</span>
            </td>
            <td style="padding: 10px;height: 18px;line-height: 18px;">￥{{ entryBillForm.total }}</td>
          </tr>
        </tbody>
      </table>
      <table class="table" cellspacing="0" cellpadding="0" style="margin:0px auto;">
        <tbody>
          <tr>
            <td style="border-top:0px;width:535px;text-align:left;padding-left:5px;font-size: 12px;line-height: 20px;">
              1、货物数量请由需方或需方代表当面点清,出库一律不负责.<br />
              2、使用前对货物进行检验确定,符合要求后方可使用.<br />
              3、如上述产品确有质量问题,需方应在一周内书面向供方提出质量异议,否则视为合格.<br />
              4、发票请于当月开清,此单盖章有效.<br />
              5、如发生纠纷,由供方所在地法院处理.</td>

            <td style="border-top:0px;vertical-align:text-top;text-align:left;padding-left:5px;">记账方式:<br />{{
        entryBillForm.state }}
            </td>
            <td style="border-top:0px;vertical-align:text-top;text-align:left;padding-left:5px;">
              制单人:<br />{{ loginUser.nickname }}</td>
            <td style="border-top:0px;vertical-align:text-top;text-align:left;padding-left:5px;width:170px;">
              收货单位经办人:(请审核无误后签字)</br></td>
          </tr>
        </tbody>
      </table>
      <div class="layui-row header-container" style="margin-top:8px;">
        <div style="width:500px; position:absolute;left:0px;top:0px;">地址:{{ loginUser.address }}</div>
        <div style="width:160px; position:absolute;left:540px;top:0px;">电话:{{ loginUser.tel }}</div>
        <div style="width:160px; position:absolute;left:772px;top:0px;">传真:{{ loginUser.fax }}</div>
      </div>
      <div class="layui-row header-container" style="margin-top:0px;">
        <div style="width:500px; position:absolute;left:0px;top:0px;">
          手机:{{ loginUser.phone3 }}&nbsp;&nbsp;{{ loginUser.phone2 }}
        </div>
      </div>
    </div>

    <!-- 
数据库修改内容
表we_company 删除
导入表we_customer, we_entry_bill, we_entry_bill_son, we_product,  
we_product_storage, we_sell, we_sell_son, we_warehouse


we_custom表改成  we_customer
所有表的 companyId 改成 organization_id  int  0  公司id
客户表 导入表we_customer type字段数据要修改成字典里的内容

we_customer 加字段拼音  
pinyin	varchar	255	0	-1	0	0	0				拼音			utf8mb4	utf8mb4_0900_ai_ci	0	0	0	0	0	0	0

we_entry_bill  warehouseName字段去掉
we_sell  warehouseName 删除
EntryBillSon   actualtotalweight;//实际总重量  去掉
we_sell_son  actualTotalWeight ;//实际总重量  去掉

we_product 加lengths negative  长度/负差
lengths	varchar	13	0	-1	0	0	0				长度			utf8mb4	utf8mb4_0900_ai_ci	0	0	0	0	0	0	0
negative	varchar	10	0	-1	0	0	0				负差			utf8mb4	utf8mb4_0900_ai_ci	0	0	0	0	0	0	0

we_product_storage 加code编码
code	varchar	30	0	-1	0	0	0				编码			utf8mb4	utf8mb4_0900_ai_ci	0	0	0	0	0	0	0

we_sell , we_entry_bill 加 unpaid 未付款金额
unpaid	decimal	11	2	-1	0	0	0				未付款金额					0	0	0	0	0	0	0


所有表的
create_time	datetime	0	0	-1	0	0	0			CURRENT_TIMESTAMP	创建时间					0	0	0	0	0	0	0
create_user	int	0	0	-1	0	0	0				创建人					0	0	0	0	0	0	0
update_time	datetime	0	0	-1	0	0	0				更新时间					0	0	0	0	0	0	0
update_user	int	0	0	-1	0	0	0				更新人					0	0	0	0	0	0	0
deleted	int	0	0	-1	0	0	0			0	del(0正常 1删除)					0	0	0	0	0	0	0

we_customer  数据都要插入到表里变成拼音

数据库 表  字段都要改  utf8mb4_general_ci
show variables where Variable_name like 'collation%';
set collation_connection = utf8mb4_general_ci

alter table we_customer convert to character set utf8mb4 collate utf8mb4_general_ci;
alter table we_entry_bill convert to character set utf8mb4 collate utf8mb4_general_ci;
alter table we_entry_bill_son convert to character set utf8mb4 collate utf8mb4_general_ci;
alter table we_product convert to character set utf8mb4 collate utf8mb4_general_ci;
alter table we_product_storage convert to character set utf8mb4 collate utf8mb4_general_ci;
alter table we_sell convert to character set utf8mb4 collate utf8mb4_general_ci;
alter table we_sell_son convert to character set utf8mb4 collate utf8mb4_general_ci;
alter table we_warehouse convert to character set utf8mb4 collate utf8mb4_general_ci;

数据表  修改  we_product  we_product_storage   we_sell_son we_entry_bill_son
理算重量   理论质量
理算总重量   总重量


all table create_time 根据当前时间戳更新
-->
  </div>
</template>

<script setup>
import { ref, reactive, computed } from 'vue';
import { toDateString } from 'ele-admin-pro';
import { printElement } from 'ele-admin-pro/es';
import useFormData from '@/utils/use-form-data';
import { message } from 'ant-design-vue';
import { TIME_OUT } from '@/config/damon';
import { useRoute, useRouter } from 'vue-router'
import dayjs from 'dayjs'
import { smallToBig } from '@/lin/utils/changeCNY'

import { pageEntryBill, getEntryBill } from '@/api/store/entryBill';
import { listEntryBillSon } from '@/api/store/entryBillSon';
import { useUserStore } from '@/store/modules/user';


const userStore = useUserStore();
const route = useRoute()
const router = useRouter()

// 登录用户信息
const loginUser = computed(() => userStore.info ?? {});

// 表单数据
const { form: entryBillForm, resetFields: entryBillResetFormFields } = useFormData({
  id: undefined,
  customer: '',
  vessel: '',
  entrytime: '',
});

const printRef = ref(null);
const print = () => {
  printElement(printRef.value);
};

let entryBillSonList = reactive({ a: [] })
/* 打开打印页面 */
const entryBillOpenEdit = () => {
  entryBillResetFormFields();
  entryBillForm.id = route.query?.id ?? 0
  if (entryBillForm.id) {
    getEntryBill(entryBillForm.id).then((data) => {
      Object.assign(entryBillForm, data ?? {});
      entryBillForm.supplier_val = data.supplier
    })

    listEntryBillSon({ entryBillId: entryBillForm.id }).then((dataSon) => {
      entryBillSonList.a = dataSon
    })

  }
};
entryBillOpenEdit()

</script>
<script>
export default {
  name: 'EntryBillPrint'
};
</script>
<style lang="less" scoped>
@import "@/assets/css/public.less";

.print {
  display: flex;
  justify-content: center;
  margin-bottom: 30px;
}

.header-container {
  width: 991px;
  margin: 0 auto;
  height: 25px;
  line-height: 25px;
  position: relative;
}

.table {
  box-sizing: border-box;
  width: 991px;
  margin: 10px auto 0 auto;
}

.table tr td {
  text-align: center;
  border: #000000 1px solid;
  height: 25px;
  line-height: 25px;
}

.layui-fluid {
  color: #000;
  font-size: 16px;
}

.marginTop {
  margin-top: 15px;
}

.table td {
  height: 25px;
}
</style>
